package mqttgw

import "fmt"

/*
设备属性上报
$oc/devices/{device_id}/sys/properties/report
网关批量上报属性
$oc/devices/{device_id}/sys/gateway/sub_devices/properties/report
*/

//Topicer ...
type Topicer interface {
	PropertiesReport() string
	SubDevicePropertiesReport() string
	SubDeviceEvent() string
}

type topic struct {
	deviceid string
}

//NewTopic is
func NewTopic(deviceid string) Topicer {
	return topic{deviceid}
}

func (topic topic) PropertiesReport() string {
	return fmt.Sprintf("$oc/devices/%s/sys/properties/report", topic.deviceid)
}

func (topic topic) SubDevicePropertiesReport() string {
	return fmt.Sprintf("$oc/devices/%s/sys/gateway/sub_devices/properties/report", topic.deviceid)
}

func (topic topic) SubDeviceEvent() string {
	return fmt.Sprintf("$oc/devices/%s/sys/events/down", topic.deviceid)
}
